import request from './request'
import {passwordHash} from '../utilities/crypto'
import {app} from '../utilities/app'
export function query ({currentPage = 1, perPage = 10, companyNo,name,staffNo,phone} = {}) {
  return request({
    url: '/staff/queryCompanyStaffInfoListPage.do',
    method: 'POST',
    body: {currentPage, perPage, companyNo,name,staffNo,phone}
  })
}
// 查询员工详情
export function queryStaffInfo ({serialNo,companyNo}) {
  return request({
    url: '/staff/queryCompanyStaffInfo.do',
    method: 'POST',
    body: {serialNo,companyNo}
  })
}
// 单条新建员工
export function createStaff ({companyNo,name, staffNo, phone, email, sex, idNo, idType, staffStatus, staffLevel}) {
  return request({
    url: '/staff/addCompanyStaffInfo.do',
    method: 'POST',
    body: {companyNo,name, staffNo, phone, email, sex, idNo, idType, staffStatus, staffLevel}
  })
}

// 单条修改员工
export function editStaff ({id,serialNo,companyNo,name, staffNo, phone, email, sex, idNo, idType, staffStatus, staffLevel}) {
  return request({
    url: '/staff/updateCompanyStaffInfo.do',
    method: 'POST',
    body: {id,serialNo,companyNo,name, staffNo, phone, email, sex, idNo, idType, staffStatus, staffLevel}
  })
}

// 单条新建积分
export function createIntegral ({staffNo,companyNo,rechargeIntegral}) {
  return request({
    url: '/staff/addStaffIntegral.do',
    method: 'POST',
    body: {staffNo,companyNo,rechargeIntegral}
  })
}

// 员工基础信息账户查询
export function seachAccountInfo ({staffNo,companyNo}) {
  return request({
    url: '/staff/queryCompanyStaffAccountInfo.do',
    method: 'POST',
    body: {staffNo,companyNo}
  })
}

// 查询企业列表（下拉框）
export function queryCompanyList () {
  return request({
    url: '/company/queryCompanyInfoList.do',
    method: 'POST',
    body: {}
  })
}
// 重置员工密码
export function reset (serialNo, pwd,verifyPwd) {
  pwd = passwordHash(pwd)
  verifyPwd = passwordHash(verifyPwd)
  return request({
    url: '/staff/resetCompanyStaffPassword.do',
    method: 'POST',
    body: {serialNo, pwd,verifyPwd}
  })
}